home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 002a / zzt.zip / LANGREF.HLP < prev    next >
Text File  |  1990-01-22  |  14KB  |  565 lines

  1. $ZZT-OOP Programming Language
  2. $Reference Manual
  3.  
  4. Contents:
  5.  
  6. !fmts;Program format
  7. !cmds;Commands
  8. !msgs;Messages
  9. !dirs;Directions
  10. !flags;Flags
  11.  
  12.  
  13. :fmts;Program Format.
  14.  
  15.      Besides direct commands, ZZT-OOP
  16. programs contain other statements that
  17. serve varying purposes.
  18.  
  19.      Each type of statement has an
  20. associated symbol:
  21.  
  22.    @  #  /  ?  :  '  !
  23.  
  24.      Their meanings:
  25.  
  26. :;     @objectname
  27. When this is on the first line of an
  28. object, it identifies the object by name.
  29. If an object is not given a name, there is
  30. no way to direct messages to it.
  31.  
  32. :;     #command
  33. Identifies a programming language command.
  34.  
  35. :;     /direction
  36. Causes the object to move in the given
  37. direction.  If it is blocked, it will wait
  38. until it is free.
  39.  
  40. :;     ?direction
  41. Tells an object to try to move in a given
  42. direction.  If its movement is blocked,
  43. the command will be ignored.
  44.  
  45. :;     :label
  46. Identifies the part of the program that
  47. handles a specified message.  Whenever
  48. the program receives the message, it
  49. will execute statements following the
  50. label.
  51.  
  52. :;     'comment
  53. Comments have no effect, but serve to
  54. remind you (the programmer) what you were
  55. doing when you wrote the program.
  56.  
  57. :;     text
  58. When program execution comes to a line of
  59. text, the text will be displayed on the
  60. screen.  If only a one-line message is
  61. given, it will be flashed on the bottom
  62. of the screen as a message.  For multiple
  63. lines, a "scroll" will be opened up on
  64. screen and the text will appear.
  65.  
  66. :;     !msg;text
  67. A hypertext-like button.  When this
  68. statement is included among text
  69. descriptions, it appears to the player
  70. as a button...
  71. !;Just like this.
  72. Then, as the users view the text, he may
  73. position the cursor on the button and
  74. press enter, causing the supplied message
  75. to be sent.
  76.    
  77.    
  78. :msgs;Messages.
  79.  
  80.      An object can send and receive
  81. (exchange) messages with itself,
  82. other objects, and the game itself.
  83.  
  84.     Messages caused by the game itself:
  85.  
  86.     TOUCH    (When player touches Program)
  87.     SHOT     (Program is hit by bullet)
  88.     BOMBED   (Bomb explodes near program)
  89.     THUD     (Program WALKs into wall)
  90.     ENERGIZE (Player touches ENERGIZER)
  91.  
  92.  
  93. :dirs;Directions:
  94.  
  95. $N, NORTH
  96. $S, SOUTH
  97. $E, EAST 
  98. $W, WEST 
  99.     Compass directions
  100. $I, IDLE 
  101.     No direction, stationary.
  102. $SEEK    
  103.     The direction toward the player
  104. $FLOW    
  105.     The direction in which the object is
  106.     currently walking.
  107. $RNDNS   
  108.     Either North or South, at random.
  109. $RNDNE   
  110.     Either North or East, at random.
  111. $CW <direction>
  112.     Clockwise from the given direction,
  113.     i.e. CW NORTH = EAST.
  114. $CCW <direction>
  115.     Counter-clockwise from the given
  116.     direction.  CW NORTH = WEST.
  117. $RNDP <direction>
  118.     A random direction perpendicular to
  119.     the given direction.  For example,
  120.     RNDP NORTH = either EAST or WEST.
  121. $OPP <direction>
  122.     Opposite the given direction. i.e.,
  123.     OPP NORTH = SOUTH.
  124.  
  125.      Here are some example commands to
  126. demonstrate the use of directions:
  127.  
  128. #GO CW RNDNS  'Go either east or west.
  129. #GO OPP SEEK  'Go away from the player.
  130. #WALK CW FLOW 'Turn clockwise from the
  131.               'direction we're walking in.
  132.  
  133.  
  134. :flags;Flag manipulation:
  135.  
  136.      Objects can manipulate simple
  137. variables called flags.  A flag assumes
  138. one of two possible states: SET and
  139. CLEAR.  Objects can alter flags, then
  140. take action accordingly.
  141.  
  142.      Flags are not associated with
  143. individual objects or rooms.  A flag set
  144. by one object can be accessed by all
  145. other objects in all rooms.
  146.  
  147.      Three commands are useful here:
  148.  
  149. :set;#SET <flag variable>
  150. :clear;#CLEAR <flag variable>
  151.      Set and clear flag variables.
  152.  
  153. :if;#IF <flag> [THEN] <message>
  154.      Tests the condition of a flag.  If
  155. the flag is SET, the message is sent.
  156. Otherwise, the instruction is ignored.
  157.  
  158.      In addition to user-declared flags,
  159. several "internal" flags can be accessed
  160. by any object:
  161.  
  162. $ALLIGNED
  163.      This flag is SET whenever the object
  164. is alligned with the player either
  165. horizontally or vertically.
  166.  
  167. $CONTACT
  168.      This flag is SET whenever the object
  169. is adjacent to (touching) the player.
  170.  
  171. $BLOCKED <direction>
  172.      This flag is SET when the object is
  173. not free to move in the given direction,
  174. and CLEAR when the object is free to
  175. move in the direction.
  176.  
  177. $ENERGIZED
  178.      This flag is SET whenever the player
  179. has touched an energizer and can not be
  180. harmed by creatures and bullets.
  181.  
  182.  
  183. :cmds;Programming commands:
  184.  
  185.      All ZZT-OOP commands are preceeded by
  186. the pound sign (#).  The following
  187. commands are supported:
  188.  
  189. !become;#BECOME <kind>
  190. !bind;#BIND <objectname>
  191. !change;#CHANGE <kind> <kind>
  192. !char;#CHAR <number>
  193. !flags;#CLEAR <flag variable>
  194. !cycle;#CYCLE <number>
  195. !die;#DIE
  196. !end;#END
  197. !endgame;#ENDGAME
  198. !give;#GIVE <item> <number>
  199. !go;#GO <direction>
  200. !idle;#IDLE
  201. !if;#IF <flag> [THEN] <message>
  202. !lock;#LOCK
  203. !play;#PLAY <sound>
  204. !put;#PUT <direction> <kind>
  205. !restart;#RESTART
  206. !restore;#RESTORE <message>
  207. !send;#SEND <message>
  208. !flags;#SET <flag variable>
  209. !shoot;#SHOOT <direction>
  210. !take;#TAKE <item> <number> [<message>]
  211. !throwstar;#THROWSTAR <direction>
  212. !try;#TRY <direction>
  213. !unlock;#UNLOCK
  214. !walk;#WALK <direction>
  215. !zap;#ZAP <message>
  216.  
  217. $Descriptions of commands:
  218.  
  219. :send;#SEND <message>
  220.  
  221.      Similar to basic's "GOTO" command.
  222. #SEND followed by the name of a label
  223. within the program will cause program
  224. execution to continue at that label.
  225.  
  226. Example:  :ABCDEF
  227.           ...program loop goes here...
  228.           #SEND ABCDEF
  229.  
  230. #SEND <objectname>:<message>
  231.  
  232.      Causes the execution of a different
  233. program to continue at a specified label
  234. within that program.  By using this
  235. command, several creatures can be
  236. coordinated.  For example, the player
  237. touches Creature A.  Creature A tells
  238. Creature B to attack the player.
  239.      
  240. Example:  :TOUCH
  241.           #SEND CreatureB:AttackPlayer
  242.  
  243. Note:     If the program receiving the
  244.           message is in the locked state,
  245.           the command will be ignored. 
  246.           See the #LOCK command for more
  247.           information.
  248.  
  249. Note:     If there are two or more
  250.           programs with the given name,
  251.           the message will be sent to
  252.           all of them.
  253.  
  254. #SEND ALL:<message>
  255.  
  256.      Sends a given message to ALL of the
  257. objects on the board.
  258.  
  259.  
  260. :end;#END
  261.  
  262.      Causes program operation to halt. 
  263. The object will just sit idly by until
  264. stimulated by a message.
  265.  
  266.  
  267. :restart;#RESTART
  268.  
  269.      Causes the program to go back to the
  270. top and start over.
  271.  
  272.  
  273. :go;#GO <direction>
  274.  
  275.      Causes an object to move in a
  276. specified direction.  The object will
  277. push boulders forward if they are in the
  278. way.  If the object can not move in the
  279. given direction, it will stand by until
  280. either it can move, or it is stimulated by
  281. a message.
  282.  
  283. !dirs;Valid directions
  284.  
  285.  
  286. :try;#TRY <direction> [<message>]
  287.  
  288.      Causes the object to move in the
  289. given direction if it is not blocked.
  290. Otherwise, the given message will be sent.
  291.  
  292.  
  293. :walk;#WALK <direction>
  294.  
  295.      Sets the object moving in the given
  296. direction.  The object will continue
  297. moving and executing commands.
  298.  
  299.      To cause a program to cease walking,
  300. issue the "Walk Idle" command:
  301.  
  302. #WALK I
  303.  
  304.      When an object WALKs into a wall, it
  305. automatically receives a THUD message.
  306.  
  307.  
  308. :idle;#IDLE
  309.  
  310.      Directs the creature to do absolutely
  311. nothing until it is updated next.  Same as
  312. the /I command.
  313.  
  314.  
  315. :endgame;#ENDGAME
  316.  
  317.      This command takes away all of the
  318. player's health, terminating the game.
  319. If the player has a high score, it will
  320. be recorded.
  321.  
  322.  
  323. :die;#DIE
  324.  
  325.      The object will instantly vanish
  326. when this command is issued.  Program
  327. execution halts, and the object is erased
  328. from the screen.  The game will continue
  329. on without it.
  330.  
  331.  
  332. :shoot;#SHOOT <direction>
  333.  
  334.      Attempts to fire a bullet in the
  335. given direction. Example:
  336.  
  337. #SHOOT SEEK   'fires a bullet
  338.               'toward the player
  339.  
  340.  
  341. :throwstar;#THROWSTAR <direction>
  342.  
  343.      Causes the object to thow a star in
  344. the given direction.  The star will try
  345. to collide with the player.
  346.  
  347.  
  348. :zap;#ZAP <message>
  349.  
  350.      Disables the first occurance of a
  351. label by turning it into a comment.  For
  352. example, #ZAP TOUCH would turn the label
  353. TOUCH into the comment 'TOUCH.  Allows a
  354. program to have several routines with the
  355. same labels, so that the desired label is
  356. called at the appropriate time.  Remember
  357. that the #SEND command always calls the
  358. first occurence of a label.  For example:
  359.  
  360.      :TOUCH 'will be called first time
  361.             'creature is touched
  362.      "You touched me for the first time"
  363.      #ZAP TOUCH
  364.      #END
  365.      :TOUCH  'will be called all
  366.              'subsequent times
  367.      "You touched me again."
  368.      #END
  369.  
  370.  
  371. :restore;#RESTORE message
  372.  
  373.      Changes a ZAPped label back into a
  374. normal label.  Then, on subsequent calls
  375. to the label, the original one will be
  376. called instead of a secondary one.
  377.  
  378.  
  379. :lock;#LOCK
  380.  
  381.      Puts a program into the "locked"
  382. state, so it will not be affected by any
  383. incomming messages.  Often, conflicts
  384. occur when two messages are sent to a
  385. program in a short amount of time.  The
  386. second message interrupts the program
  387. before it can finish handling the first
  388. one.  However, if a program LOCKs itself
  389. when dealing with messages, it can not be
  390. disturbed.
  391.  
  392. :unlock;#UNLOCK
  393.  
  394.      Removes a program from the "locked"
  395. state, so it is free to receive incomming
  396. messages.  Any messages that happened to
  397. arrive while it was LOCKed are lost.
  398.  
  399. Example:  :TOUCH
  400.           #LOCK
  401.           'code to handle "touch"
  402.           'message goes here...
  403.           #UNLOCK
  404.           #END
  405.  
  406.  
  407. :give;#GIVE <item> <quantity>
  408.  
  409.      Gives a certain quantity of an item
  410. to the player.  Good for giving bonus
  411. points, selling ammo, awarding extra
  412. health, etc.
  413.  
  414.      Items:
  415.      AMMO
  416.      GEMS
  417.      TORCHES
  418.      ENERGY
  419.      SCORE
  420.  
  421. Example:  #GIVE AMMO 10  (gives the player
  422.           10 extra shots)
  423.  
  424.  
  425. :take;#TAKE <item> <quantity> [<message>]
  426.  
  427.      Attempts to take a certain quantity
  428. of an item from the player.  If the player
  429. does not have the given amount, none will
  430. be taken, and if a message is given, it
  431. will be sent.
  432.  
  433. Example:  #TAKE GEMS 2 TooPoor
  434.           "Thank you for the gems!"
  435.           #END
  436.           :TooPoor
  437.           "You don't have enough gems!"
  438.           #END
  439.  
  440.  
  441. :play;#PLAY <music>
  442.  
  443.      Plays a musical score in the
  444. background as the game continues.
  445.  
  446.      Music:
  447.  
  448.      _> [Optional parameters] [Notes] <_
  449.     /                                   \
  450.     \___________________________________/
  451.  
  452.      Parameters:
  453.  
  454.      T    32nd note follows
  455.      S    Sixteenth
  456.      I    Eighth
  457.      Q    Quarter
  458.      H    Half
  459.      W    Whole
  460.      3    Triplets: cut previous duration
  461.           into thirds. For example,
  462.           "Q3ABC" would play the notes A,
  463.           B, and C, with all three taking
  464.           up the time of a quarter note.
  465.      .    Adds time-and-a-half.  For
  466.           example, "H." would turn a half-
  467.           note into a half-note tied to a
  468.           quarter note.
  469.      +    Up octave
  470.      -    Down octave
  471.      
  472. $Notes & rests:
  473.      X    Rest
  474.      A-G  Piano notes, can be followed by:
  475.      #    Sharp
  476.      !    Flat
  477.  
  478. $Rythmic sound effects:
  479.      0    Tick
  480.      1    Tweet
  481.      2    Cowbell
  482.      3    <<no effect, denotes triplet>>
  483.      4    Hi snare
  484.      5    High woodblock
  485.      6    Low snare
  486.      7    Low tom
  487.      8    Low woodblock
  488.      9    Bass drum
  489.  
  490.  
  491. :change;#CHANGE <kind> <kind>
  492.  
  493.      Changes every specified item on the
  494. board into another item.  <Kind> is the
  495. name of an item, creature, or terrain as
  496. listed in the editor (by pressing f1, f2,
  497. or f3), but with all punctuation and
  498. spaces removed.  Examples:
  499.  
  500. #CHANGE LION GEM 'Turns all lions on
  501.                  'the board into gems.
  502. #CHANGE KEY SLIDEREW  'Changes all keys
  503.                  'into east-west sliders.
  504. #CHANGE RED KEY CONVEYOR1 'Changes all red
  505.                  'keys into conveyors.
  506.  
  507.  
  508. :put;#PUT <direction> <kind>
  509.  
  510.      This causes a specified item to be
  511. placed adjacent to the object issuing the
  512. command.  Examples:
  513.  
  514. #PUT N BLUE KEY  'Places a blue key
  515.                  'north of us.
  516. #PUT SEEK TIGER  'Puts a tiger in the
  517.                  'direction of the player.
  518.  
  519. !change;What does <Kind> mean?
  520.  
  521.  
  522. :become;#BECOME <kind>
  523.  
  524.      Causes the object to suddenly change
  525. form into a specified item or creature.
  526. The object's program then ceases to
  527. exist.
  528.  
  529. !change;What does <kind> mean?
  530.  
  531.  
  532. :char;#CHAR <number>
  533.  
  534.      Causes the object to change form, so
  535. that it is reprented on the screen as a
  536. different character.  <Number> can range
  537. from 0 to 255, and should be the ASCII
  538. code of the new character.  Find a manual
  539. with a list of ASCII codes for reference.
  540.  
  541.  
  542. :cycle;#CYCLE <number>
  543.  
  544.      Sets the speed at which an object is
  545. updated.  This can range from 1 (fastest)
  546. to 255 (ridiculusly slow.)  When no CYCLE
  547. speed is specified, it defaults to 3.
  548.  
  549.  
  550. :bind;#BIND <objectname>
  551.  
  552.     When a Program executes this
  553. instruction, it's code will be replaced
  554. by the code of another object, and it will
  555. start executing instructions from the
  556. beginning.
  557.  
  558.     This is a useful and space-saving
  559. technique.  Rather than creating ten
  560. objects with the same program (which
  561. would be stored in memory ten times),
  562. create one object with the program, and
  563. nine others that contain only a BIND
  564. statement.
  565.